package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.SysDocset;
import com.ruoyi.system.domain.SysGroup;
import com.ruoyi.system.domain.SysVgroup;
import com.ruoyi.system.service.ISysGroupService;
import com.ruoyi.system.service.ISysVgroupService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysRegset;
import com.ruoyi.system.service.ISysRegsetService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-01-10
 */
@Controller
@RequestMapping("/system/regset")
public class SysRegsetController extends BaseController
{
    private String prefix = "system/regset";

    @Autowired
    private ISysRegsetService sysRegsetService;
    @Autowired
    ISysGroupService iSysGroupService;
    @Autowired
    ISysVgroupService iSysVgroupService;
    @RequiresPermissions("system:regset:view")
    @GetMapping()
    public String regset(ModelMap mmap)
    {
        SysRegset sysDocset = sysRegsetService.selectSysRegsetList(new SysRegset()).get(0);
        List<SysGroup> sysGroupList = iSysGroupService.selectSysGroupList(new SysGroup());
        SysVgroup sysVgroup = new SysVgroup();
        sysVgroup.setState(1);
        List<SysVgroup> sysVgroupList = iSysVgroupService.selectSysVgroupList(sysVgroup);
        mmap.put("sysGroupList",sysGroupList);
        mmap.put("sysVgroupList",sysVgroupList);
        mmap.put("sysDocset", sysDocset);
        return prefix + "/regset";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:regset:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysRegset sysRegset)
    {
        startPage();
        List<SysRegset> list = sysRegsetService.selectSysRegsetList(sysRegset);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:regset:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysRegset sysRegset)
    {
        List<SysRegset> list = sysRegsetService.selectSysRegsetList(sysRegset);
        ExcelUtil<SysRegset> util = new ExcelUtil<SysRegset>(SysRegset.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:regset:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysRegset sysRegset)
    {
        return toAjax(sysRegsetService.insertSysRegset(sysRegset));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:regset:edit")
    @GetMapping("/edit/{email}")
    public String edit(@PathVariable("email") Long email, ModelMap mmap)
    {
        SysRegset sysRegset = sysRegsetService.selectSysRegsetByEmail(email);
        mmap.put("sysRegset", sysRegset);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:regset:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysRegset sysRegset)
    {
        return toAjax(sysRegsetService.updateSysRegset(sysRegset));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:regset:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysRegsetService.deleteSysRegsetByEmails(ids));
    }
}
